using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace RFCReader
{
    public partial class SettingForm : Form
    {
        public SettingForm()
        {
            InitializeComponent();
            lb_Table.Text = @"Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   6
     1.1.  Motivation  . . . . . . . . . . . . . . . . . . . . . . .   6
       1.1.1.  Existing Protocols  . . . . . . . . . . . . . . . . .   6
       1.1.2.  Assumptions . . . . . . . . . . . . . . . . . . . . .   7
     1.2.  Architectural View  . . . . . . . . . . . . . . . . . . .   8
     1.3.  Functional View . . . . . . . . . . . . . . . . . . . . .  10
       1.3.1.  API Adapters  . . . . . . . . . . . . . . . . . . . .  11
       1.3.2.  Address Subscription  . . . . . . . . . . . . . . . .  11
       1.3.3.  Address Distribution  . . . . . . . . . . . . . . . .  11
       1.3.4.  Address Translation . . . . . . . . . . . . . . . . .  11
       1.3.5.  Multicast . . . . . . . . . . . . . . . . . . . . . .  11
       1.3.6.  Connection Supervision  . . . . . . . . . . . . . . .  12


                         TIPC User

    ----------------------------------------------------------
           -------------    -----------     -------------
          |   Socket    |  |  Port     |   |  Other API
          |   Adapter   |  |  Adapter  |   |  Adapters..
           -------------    -----------     -------------
    =========================================================
";
            T_Font = Config.Instance.Font;
            T_BackColor = Config.Instance.BackColor;
            T_ForeColor = Config.Instance.ForeColor;
            C_ForeColor = Config.Instance.LineCommentColor;
            C_BackColor = Config.Instance.CommentBackColor;
            C_YGBColor = Config.Instance.YGBColor;
            ck_AutoSave.Checked = Config.Instance.AutoSave;

        }
        public Color T_BackColor = Color.White;
        public Color T_ForeColor = Color.Black;
        public Color C_BackColor = Color.Pink;
        public Color C_ForeColor = Color.Black;
        public Color C_YGBColor = Color.Pink;
        public Font T_Font = new System.Drawing.Font("Courier New", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        private void bt_BackColor_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();
            if (cd.ShowDialog() == DialogResult.OK)
            {
                lb_Table.BackColor = cd.Color;
                T_BackColor = cd.Color;
            }
        }

        private void bt_ForeColor_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();
            if (cd.ShowDialog() == DialogResult.OK)
            {
                lb_Table.ForeColor = cd.Color;
                T_ForeColor= cd.Color;
            }
        }

        private void btc_BackColor_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();
            if (cd.ShowDialog() == DialogResult.OK)
            {
                lb_Comment.BackColor = cd.Color;
                C_BackColor = cd.Color;
            }
        }

        private void btc_ForeColor_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();
            if (cd.ShowDialog() == DialogResult.OK)
            {
                lb_Comment.ForeColor = cd.Color;
                C_ForeColor = cd.Color;
            }
        }

        private void bt_Font_Click(object sender, EventArgs e)
        {
            FontDialog cd = new FontDialog();
            if (cd.ShowDialog() == DialogResult.OK)
            {
                lb_Table.Font= cd.Font;
                lb_Comment.Font = cd.Font;
                T_Font = cd.Font;
            }
        }

        private void bt_OK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            Close();
        }

        private void SettingForm_Shown(object sender, EventArgs e)
        {
            lb_Table.Font = T_Font;
            lb_Comment.Font = T_Font;
            lb_Table.BackColor = T_BackColor;
            lb_Table.ForeColor = T_ForeColor;
            lb_Comment.BackColor = C_BackColor;
            lb_Comment.ForeColor = C_ForeColor;
            

        }

        private void bt_YGB_Click(object sender, EventArgs e)
        {
            ColorDialog cd = new ColorDialog();
            if (cd.ShowDialog() == DialogResult.OK)
            {
                lb_YGB.BackColor = cd.Color;
                C_YGBColor = cd.Color;
            }
        }

        private void ck_AutoSave_CheckedChanged(object sender, EventArgs e)
        {
            Config.Instance.AutoSave = ck_AutoSave.Checked;
        }
    }
}